<template>
	<view class="container">
		<view class="header">
			<u-swiper :list="list"  bg-color="#fff"></u-swiper>
			<u-notice-bar mode="horizontal" :list="notice"></u-notice-bar>
			<!-- <u-gap height="20" bg-color="#fff"></u-gap> -->
		</view>
		<view class="main">
			<view class="main-title">
				<u-row justify="center">
					<u-col span="4">
						<view class="trad-data">
							<view>{{usMoney}}</view>
							<view>今日聚合收款（元）</view>
						</view>
					</u-col>
					<u-col span="4">
						<view class="trad-data">
							<view>{{onlineMoney}}</view>
							<view>今日线上收款（元）</view>
						</view>
					</u-col>
					<u-col span="4">
						<view class="trad-data">
							<view>{{count}}</view>
							<view>今日交易总数（条）</view>
						</view>
					</u-col>
				</u-row>
			</view>
			<view class="main-item">
				<u-section title="服务商功能" :right="false"></u-section>
				<view class="btn-group">
					<u-grid :col="3" :border="false" >
						<u-grid-item>
							<navigator url="../order-list/index" hover-class="navigator-hover">
								<u-icon name="order" :size="46" color="#f29100"></u-icon>
								<view class="grid-text">订单列表</view>
							</navigator>
						</u-grid-item>
						<u-grid-item>
							<navigator url="../mht-list/mer-type" hover-class="navigator-hover">
								<u-icon name="plus-circle" :size="46" color="#2b85e4"></u-icon>
								<view class="grid-text">新增商户</view>
							</navigator>
						</u-grid-item>
						<u-grid-item>
							<navigator url="../mht-list/index" hover-class="navigator-hover">
								<u-icon name="account" :size="46" color="#2b85e4"></u-icon>
								<view class="grid-text">商户列表</view>
							</navigator>
						</u-grid-item>
						<u-grid-item>
							<navigator url="../center/index" hover-class="navigator-hover">
								<u-icon name="account" :size="46" color="#2b85e4"></u-icon>
								<view class="grid-text">个人资料</view>
							</navigator>
						</u-grid-item>
						<u-grid-item @click="logout">
							<!-- <navigator url="../ccc/ccc" hover-class="navigator-hover"> -->
								<u-icon name="fingerprint" :size="46" color="#2b85e4"></u-icon>
								<view class="grid-text">退出</view>
							<!-- </navigator> -->
						</u-grid-item>
					</u-grid>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: [{
						image: 'https://qiniu.hiima.cn/9b20c26376a9301fa0242a07b8a25c24857ea3481619424484.jpg',
						title: '昨夜星辰昨夜风，画楼西畔桂堂东'
					},
					{
						image: 'https://qiniu.hiima.cn/344333f587b9156ee7be8ffef20499fc11c4943f1619424512.jpg',
						title: '身无彩凤双飞翼，心有灵犀一点通'
					},
				],
				notice: [
					'全国各地区招商',
					'火热进行中',
				],
				count:0,
				onlineMoney:0,
				usMoney:0,
			}
		},
		onLoad() {  //userInfo
		 //判断权限
		 if(uni.getStorageSync('rule') == 1){ //商家
			 uni.reLaunch({
			 	url: '/pages/index/merchant-index'
			 });
		 }
			let that = this;
			this.$request.httpTokenRequest({   
				url: '/admin/statistical/mobileCount',
				method: 'POST',
				data: {
					rule: uni.getStorageSync('rule'),
					userID: uni.getStorageSync('userID'),
				},
				// needToken: false,
			}).then(res => {
				console.log(res)
				if (res.data.code == 200) {
			      that.count = res.data.content.count;
			      that.onlineMoney = res.data.content.onlineMoney;
			      that.usMoney = res.data.content.usMoney;
				}
			}, error => {
				
			});
		},
		methods: {
			logout(){
				var token=uni.getStorageSync('token');
				let that = this;
				this.$request.httpTokenRequest({
					url: '/admin/login/loginOut',
					method: 'POST',
					data: {
						token: token
					},
					// needToken: false,
				}).then(res => {
					if (res.data.code == 200) {
						uni.showToast({
							title:'退出成功',
							icon:'success',
							duration:2000
						});
						uni.clearStorageSync();
						var timer=setTimeout(()=>{
							uni.reLaunch({
								url: '/pages/login/login' 
							});
							timer=null
						},1000);
					}else{
						uni.showToast({
							title:res.data.msg,
							icon:'none',
							duration:2000
						});
					}
				}, error => {
					
				});
				
			}
		}
	}
</script>

<style lang="scss" scoped>
	.container {
		padding-bottom: 1rem;
		.header{
			// margin-top: 20rpx;
		}
	}
	.main {
		.main-title{
			width: 100%;
			padding: .5rem 0;
			border-bottom: .01rem solid $u-type-info-disabled;
			.trad-data{
				text-align: center;
				view:first-child{
					font-size: .8rem;
					line-height: 1.3rem;
					font-weight: 600;
				}
			}
		}
		.main-item {
			width: 96%;
			margin: .6rem auto 0 auto;
			// margin-top: .6rem;

			.btn-group {
				width: 90%;
				margin: .6rem auto 0 auto;
				navigator{
					text-align: center;
					.grid-text{
						font-size: .5rem;
						line-height: 1.5rem;
					}
				}
			}
		}

	}
</style>
